﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Avalonia.Data.Converters;

namespace AvaloniaApplication1.Converters
{
    public class LevelVisibleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value==null)
            {
                return false;
            }

            try
            {
                bool IsConverterSuccess = int.TryParse(value.ToString(), out int level);
                if (!IsConverterSuccess)
                {
                    return false;
                }

                if (level != 0)
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                return false;
            }
           

            return true;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
